﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Autofac;
using Autofac.Builder;
using Autofac.Modules;
using Vulcano.Helpers;


namespace DatetimeTests
{
    public class AutofacConfig
    {
        public static IContainer Configure(string Namespace)
        {

            var builder = new ContainerBuilder();
            builder.RegisterModule(new ImplicitCollectionSupportModule());
            var parsers = from type in Assembly.Load("Vulcano.Helpers").GetTypes()
                          where typeof(IDateTimeParser).IsAssignableFrom(type) &&
                          type.Namespace == Namespace
                          select type;

            foreach (var parser in parsers)
            {
                builder.Register(parser).As<IDateTimeParser>().FactoryScoped().SingletonScoped();
            }

            return builder.Build();

        }
    }

   

}
